<template>
  <el-time-picker
    v-model="timeValue"
    v-bind="$attrs"
    :format="format"
    :value-format="valueFormat"
    :size="size"
    :disabled="disabled"
    :clearable="clearable"
    :placeholder="placeholder"
    @change="handleChange"
    @focus="handleFocus"
    @blur="handleBlur"
  />
</template>

<script setup>
import { computed } from 'vue'
import { ElTimePicker } from 'element-plus'

const props = defineProps({
  modelValue: [String, Date],
  format: {
    type: String,
    default: 'HH:mm:ss'
  },
  valueFormat: {
    type: String,
    default: 'HH:mm:ss'
  },
  size: String,
  disabled: Boolean,
  clearable: {
    type: Boolean,
    default: true
  },
  placeholder: String
})

const emit = defineEmits(['update:modelValue', 'change', 'focus', 'blur'])

const timeValue = computed({
  get() {
    return props.modelValue
  },
  set(value) {
    emit('update:modelValue', value)
  }
})

const handleChange = (value) => {
  emit('change', value)
}

const handleFocus = (event) => {
  emit('focus', event)
}

const handleBlur = (event) => {
  emit('blur', event)
}
</script>